1. Technical Field
The present invention relates to a quantization device, and more particularly to an audio quantization coding and decoding device and a method thereof.
2. Related Art
A voice signal is originally an analogue signal, and after being digitized and compressed, distortion may be generated. Generally, the higher the compression rate is, the larger the signal distortion is, but the lower the required transmission data rate is. Therefore, when the transmission bandwidth is insufficient, under a condition of capable of recognizing talking content, usually a protocol with a higher compression rate may be selected. If the problem of the transmission bandwidth does not exist, usually the G.711 protocol with the smaller signal distortion is a better selection.
Please refer to FIG. 1, which is a voice coding and decoding system diagram of the prior art, which includes: a voice input signal 100, a voice coder 200, a memory 300, a voice decoder 400, and a voice output signal 500. The voice input signal 100 is a real sound, and is an analogue signal. For example, when the input of voice coder 200 is 8 KHz sample rate, mono, 16-bit word length data, the data rate is 128 k bit-per-second (bps). When the voice input signal 100 is input to the voice coder 200, the voice input signal 100 is sampled as a 128 kbps mono digital data, then is compressed and coded, and is stored in the memory 300. The voice coder 200 is a compressor during practical application. In the practical application, sometimes in order to reduce the memory 300 usage, usually the voice data of 16-bit word length is compressed to the data with a lower resolution (for example, 5 bit or 4 bit), and the data is stored in the memory 300, so as to effectively reduce the memory 300 usage. Finally, the voice decoder 400 decodes the compressed data with the lower resolution stored in the memory 300, converts the data to the single track voice data of 16 bit, and converts the data to the voice output signal 500.
Please refer to FIG. 2A, which is a detailed block diagram of the voice coder 200 of the prior art. The voice coder 200 includes an analogue to digital converter 210, a word length converter 220, a quantizer 230, and a data coder 240. The analogue to digital converter 210 receives the analogue voice input signal and converts the analogue voice input signal to the digital first voice data. The word length converter 220 is connected to the analogue to digital converter 210, and performs word length reduction on the first voice data. The quantizer 230 is connected to the word length converter 220, receives the first voice data and performs quantization to generate a digital codeword which includes sign bit and numeric data. The data coder 240 is connected to the quantizer 230, and receives at least one digital codeword to generate an encoded voice data stream.
In another conventional implementation manner, please refer to FIG. 2B, in which an external first memory 110 stores the first voice data, in which the word length converter 220 performs the word length reduction on the first voice data. The quantizer 230 is connected to the word length converter 220, receives the first voice data and performs the quantization to generate a digital codeword which includes the sign bit and the numeric data. The data coder 240 is connected to the quantizer 230, and receives at least one digital codeword to generate an encoded voice data stream.
An example is given in the following.
Please refer to FIG. 3, in which the voice data of 16-bit word length converted by the analogue to digital converter 210 includes 7 batches of first voice data: 1111101100001000, 1111001100001000, 1111111100001000, 0000000100001000, 0000010100001000, 0000100000001000, and 0000111100001000. The word length converter 220 converts the 7 batches of first voice data of 16 bit to the first voice data of 8 bit having negative and positive signs. The word length converter 220 directly removes the 1st bit to the 8th bit in the first voice data of 16 bit, only the 9th to the 16th data of the original first voice is retained, and the retained data is the new first voice data. Therefore, the first voice data is finally the data of 8 bit having the positive and negative signs, and a data range is from −128 to 127. The 1st bit to the 7th bit represent the numeric data (the magnitude of the voice signal), and the 8th bit represents the sign bit (the positive or the negative value of the voice signal). Therefore, after the word length converter 220 performs the word length reduction on the first voice data, the 7 new obtained first voice data is 11111011, 11110011, 11111111, 00000010, 00000101, 00001000, and 00001111 (−5, −13, −1, 2, 5, 8, 15).
Next, the quantizer 230 quantizes the first voice data to generate the digital codeword, and the quantization process may be performed by using a table look-up method. Although the voice data may be positive or negative, in order to save the using of the memory, usually only a quantization table of positive value is established. Before the quantization procedure, firstly the sign-bit representing the signal polarity is recorded, then an absolute value is taken from the voice data, and the voice data is quantized by using the positive valued quantization table. In the following, a table of 5 bit is given as an example, the first voice data (−5, −13, −1, 2, 5, 8, 15) is quantized by using the quantization table 1. For example, the sign-bit of the voice data −5, −13, −1 is recorded as 1, but the sign-bit of 2, 5, 8, 15 is recorded as 0, and the absolute value is taken from all the data to obtain (5, 13, 1, 2, 5, 8, 15) in which for 5, an optimal index codeword obtained according to the quantization table 1 is 3, and a corresponding quantization binary index codeword is 00011, and for 13, an optimal index codeword obtained according to the quantization table 1 is 7, and a corresponding quantization binary index codeword is 00111, then the numeric data after the sign-bit is added to the 5th bit is respectively 10011 and 10111.
Therefore, for the absolute value of the first voice data (−5, −13, −1, 2, 5, 8, 15), the index codeword obtained according to Table 1 is (3, 7, 1, 2, 3, 4, 7) under the minimum absolute error criterion. The corresponding binary digital codeword is (00011, 00111, 00001, 00010, 00011, 00100, 00111) and the binary digital codeword after the sign-bit is replaced at the 5th bit is (10011, 10111, 10001, 00010, 00011, 00100, 00111).
TABLE 1Binary index codewordIndex codewordQuantization table0000000000011100010220001135001004800101590011061000111715010008300100194001010104501011115001100125501101136001110149001111151001111131Frame switch control code
During the practical application, in order to reduce the quantization error, usually multiple quantization tables are used for different dynamic ranges. Please refer to FIG. 4, in which the digital code 600 is formed by the sign bit 612 and the numeric data 614. The encoded voice data stream is formed by multiple digital codewords, and 7 batches of the digital code 600 has a data amount of totally 35 bit. The encoded voice data stream usually also includes frame header 606. The frame header 606 records the index of the optimal quantization table corresponding to the current frame, and the frame switch control code (usually a unique non-used codeword is adopted). The data length of the frame header 606 is determined according to the number of the quantization tables, for example, when 8 quantization tables are adopted, the frame header 606 needs 3 bits to represent the index of the optimal quantization table, and when 32 quantization tables are adopted, the frame header 606 needs 5 bits to represent the index of the optimal quantization table. Taking the length of the frame header being 10 bits as an example (frame switch control code of 5 bits plus index of the optimal quantization table of 5 bits), the length of the tandem voice data is 35+10=45 bits after being coded. Therefore, the original 7 batches of the first voice data of 16 bits have a total of 112 bits, and the word length converter 220 converts the 7 batches of data of 16 bits to only 7 batches of first voice data of 8 bits totally having 56 bits. Then, by using a quantization result of the quantizer 230, each batch of data of 8 bits (table code), is changed to the index codeword data of 5-bit, and finally the data amount of the 7 batches of 5-bit data is 35 bits. It may be known that the original data amount of 112 bits is reduced to 35 bits through the word length converter 220 and the quantizer 230. Afterwards, the frame header 606 of 10 bit is added, and the final data amount is 45 bit.
From the above prior art, during the voice quantization process, each quantized digital codeword has the sign bit and the numeric data. It is a waste for each digital codeword to include the sign bit. Therefore, in order to reduce the waste of the data storage, it is necessary to provide a new architecture.